package com.qiang.test01;

import java.io.File;
import java.io.IOException;

public class Demo02 {
    public static void main(String[] args) throws IOException {
        File file = new File("D:\\xx");
        boolean mkdirs = file.mkdirs();
        System.out.println(mkdirs);

        File file1 = new File(file, "\\AA.txt");
        System.out.println(file1.createNewFile());

        File file2 = new File("D:\\xx\\BB.txt");
        System.out.println(file2.createNewFile());

        //创建方法，删除文件夹（全部），使用递归

        deleteDir(file);

    }

    private static void deleteDir(File file) {

        //获取文件夹李彪
        File[] files = file.listFiles();

        //遍历

        for (File file1 : files) {

            if (file1.isFile()) {
                file1.delete();
            } else {
                //调用自己
                deleteDir(file1);
            }
        }
        file.delete();
    }
}
